<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class JR_Plugin
{
	function __get($property_name)
	{
		if($property_name=='load')
		{
			$ci = & get_instance();
			if(!isset($ci->plugin_load))
			{
				$ci->plugin_load = clone $ci->load;
				$ci->plugin_load->remove_package_path();
				$ci->plugin_load->work_space = "plugin"; 
			}
			return $ci->plugin_load; 
		}
		else
		{
			$ci = &get_instance();
			$this->$property_name = $ci->$property_name;
		}
		return $this->$property_name;
	}
	
	function __construct()
	{
		$class_name = get_class($this);
		$path = APPPATH."plugins/".trim($class_name,"_plugin")."/";
		$this->load->remove_package_path(); 
		$this->load->add_package_path($path);
	}
	
	public function is_postback()
	{
		$ci = & get_instance(); 
		return $ci->is_postback();
	}
}